
#include <stdint.h>
#include "regs.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include "hisi_memmap.h"
#include <string.h>

#define DEFAULT_MD_LEN 128
#define ID_ADDR (0x12020400)

extern "C" void Get_die_id(unsigned char *buff, int sz)
{
	void *mem_addr = memmap(ID_ADDR, DEFAULT_MD_LEN);

	volatile uint32_t *addr = (uint32_t *)mem_addr;

	uint32_t tmplen[6];
	for (int i = 0; i < 6; i++) {
		tmplen[i] = addr[i];
	}

	memcpy(buff, tmplen, sz >= 24 ? sz : 24);

	munmap((void *)addr, DEFAULT_MD_LEN);
}
